﻿@model KacincisinProject.ViewModels.SoruViewModel
@{
    ViewBag.Title = "SoruOlustur";
}
<style type="text/css">
    .cke_chrome {
        width: 400px;
    }

    .cke_inner {
        width: 400px;
    }
</style>
<br />
<br />
<h2>Soru Oluştur</h2>
@using(Html.BeginForm("SoruOlustur", "Soru", FormMethod.Post, new Dictionary<string, object> { { "class", "form-horizontal" } }))
{
    <fieldset>
        <legend>Soru Kategorisi Oluştur</legend>
        <div class="control-group">
            <label class="control-label" for="SoruKategoriId">Soru Kategorisi</label>
            <div class="controls">
                @Html.DropDownListFor(model => model.SoruKategoriId, (SelectList)ViewBag.SoruKategorileri) &nbsp; <span style="color: red">@Html.ValidationMessageFor(model => model.SoruKategoriId)</span>
            </div>
        </div>
        <div class="control-group">
            <label class="control-label" for="SoruKategoriId">Zorluk Derecesi</label>
            <div class="controls">
                <select disabled="disabled">
                    <option>4.4</option>
                </select>
                @Html.Hidden("ZorlukDerecesi", 4.4)
            </div>
        </div>
        <div class="control-group">
            <label class="control-label" for="SoruKategoriId">Soru İçeriği</label>
            <div class="controls">
                @Html.TextAreaFor(model => model.SoruIcerigi)
            </div>
        </div>
        <div class="control-group">
            <label class="control-label" for="SoruKategoriId">Doğru Cevap</label>
            <div class="controls">
               @Html.TextBoxFor(model => model.DogruCevap)
            </div>
        </div>
        <div class="control-group">
            <div class="controls">
                <button type="submit" class="btn">Oluştur</button>
            </div>
        </div>
    </fieldset>
}
@section scripts
{
    @Scripts.Render("~/bundles/jqueryval")
    <script src="@Url.Content("~/ckeditor/ckeditor.js")" type="text/javascript"></script>
    <script type="text/javascript" src="@Url.Content("~/ckeditor/adapters/jquery.js")"></script>
    <script src="@Url.Content("~/ckeditor/config.js")" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            $('#SoruIcerigi').ckeditor();
            CKEDITOR.instances['SoruIcerigi'].setData('@Model.SoruIcerigi');
            
            $('form').submit(function (e) {                
                var value = CKEDITOR.instances['SoruIcerigi'].getData();
                if ($.trim(value) == '') {
                    alert('Lütfen soru içeriği giriniz.');
                    e.preventDefault();
                    return false;
                }
            });

        });
        //var value = CKEDITOR.instances['DOM-ID-HERE'].getData()
    </script>
}
